package com.example.yilanchatserver.application.controller;

import com.example.yilanchatserver.business.freechat.service.UtopiaService;
import com.example.yilanchatserver.business.freechat.service.ZhiPuService;
import com.example.yilanchatserver.business.freechat.service.dto.UtopiaChatDTO;
import com.example.yilanchatserver.business.freechat.service.dto.UtopiaResetDTO;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/metah/utopia")
public class UtopiaController {

    @Resource
    private UtopiaService utopiaService;


    @PostMapping("/get")
    public String getChat(@RequestBody UtopiaChatDTO utopiaChatDTO) throws Exception {
        return utopiaService.getChat(utopiaChatDTO);
    }

    @GetMapping("/chatStreaming")
    public ResponseEntity<StreamingResponseBody> chatStreaming(@RequestBody UtopiaChatDTO utopiaChatDTO) throws Exception {
        return utopiaService.chatStreaming(utopiaChatDTO);
    }


    @PostMapping("/resetChat")
    public void resetChat(@RequestBody UtopiaResetDTO utopiaResetDTO) throws Exception {
        utopiaService.resetChat(utopiaResetDTO);
    }

    @GetMapping("/application/getId")
    public Map getRoleId(@RequestParam Long spaceId) throws Exception {
        return utopiaService.getRoleId(spaceId);
    }
}
